<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>卖家-修改个人信息</title>
<link href="<?php echo $this->_webroot('/user/css/common.css'); ?>" rel="stylesheet" type="text/css" />
<link href="<?php echo $this->_webroot('/user/css/content1.css'); ?>" rel="stylesheet" type="text/css" />
<script src="<?php echo $this->_webroot('/user/js/jquery-1.7.1.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo $this->_webroot('/user/js/common.js'); ?>" type="text/javascript"></script>

<style type="text/css">
.red { color:red; }
.edit span{background:#efefef;}
.search {margin:5px;}
.search input {color:#444;}
.clear {clear:both;}
td{text-align:left;}
#bgdiv { background-color:#333; position:absolute; width:965px; left:230px; top:130px; opacity:0.4; filter:alpha(opacity=40); height:1313px; z-index:960}
#category_select { width:680px; z-index:961; position:absolute; filter:alpha(opacity=95); left:400px; top:350px; background-color:#fff; height:270px}
.category_title_1 {background:#FFE1C2; color:#F67A06; padding-left:10px; line-height:25px; font-weight:bold; font-size:14px;}
.category_title_1 span {float:right; padding-right:5px; cursor:pointer;}
.ulselect {width:168px; height:200px; overflow-x:hidden; margin-bottom:10px; overflow-y:scroll; border:1px solid #efefef; float:left;}
.ulselect li {line-height:21px; padding-left:5px; cursor:pointer;width:100%;float:left;text-align:left;}
.ulselect li:hover {background:#F6A248; color:#fff;}
.ulselect li.select {background:#F6A248; color:#fff;}
.category_com {height:30px; padding-bottom:10px; line-height:30px; text-align:center;}
.attr_class { background:#FFF2E6; }
.attr_class div.div {border:2px solid #fff; padding:3px;}
.attr_class div span.left{display:block; width:150px; float:left; margin-left:10px; text-align:right; _line-height:24px;}
.attr_class div span.right{display:block; width:350px; float:left; margin-left:5px; text-align:left;}
.attr_class div span.right input {margin-left:5px;}

#picspan {width:82px; height:82px; padding:1px; border:1px solid #efefef; line-height:80px; text-align:center; display:inline-block; overflow:hidden; float:right;}
</style>

<script type="text/javascript" src="<?php echo $this->_webroot('servtools/jquery-1.3.2.min.js?v=1.3.2'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('servtools/xheditor/xheditor.min.js?v=1.0.0-final'); ?>"></script>
<link href="<?php echo $this->_webroot('servtools/swfupload/css/default.css'); ?>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo $this->_webroot('servtools/swfupload/swfupload.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('servtools/swfupload/swfupload.queue.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('servtools/swfupload/fileprogress.js'); ?>"></script>
<script type="text/javascript" src="<?php echo $this->_webroot('servtools/swfupload/handlers.js'); ?>"></script>



<script type="text/javascript">
		var swfu;
		window.onload = function() {
			var settings = {
				flash_url : "<?php echo $this->_webroot('servtools/swfupload/swfupload.swf'); ?>",
				upload_url: "<?php echo $this->_url('goods/swfupload');?>",
				post_params: {"<?php echo Param::read('Session.postOrGetIdName');?>" : "<?php echo $ps; ?>","gcv":"881257c8fab1044a7f6082c12fe4ee92"},
				file_size_limit : "<?php echo Param::read('upfiles.sizelimit');?> MB",
				file_types : "<?php echo Param::read('upfiles.type');?>",
				file_types_description : "images Files",
				file_upload_limit : 30,
				file_queue_limit : 30,
				file_post_name:"Filedata[]",
				custom_settings : {
					progressTarget : "fsUploadProgress",
					cancelButtonId : "btnCancel"
				},
				debug: false,

				
				button_image_url: "<?php echo $this->_webroot('servtools/swfupload/images/TestImageNoText_65x29.png'); ?>",
				button_width: "65",
				button_height: "29",
				button_placeholder_id: "spanButtonPlaceHolder",
				button_text: '<span class="theFont">上传图片</span>',
				button_text_style: ".theFont { font-size: 12; }",
				button_text_left_padding: 5,
				button_text_top_padding: 3,
				button_window_mode : SWFUpload.WINDOW_MODE.OPAQUE,
				button_cursor : SWFUpload.CURSOR.HAND,
				
				
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadGoodsSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete	// Queue plugin event
			};

			swfu = new SWFUpload(settings);
			bodyonload();
			menu_style_change('goods_list');
			changeMenu();
	     };
	</script>
<script type="text/javascript">
var introeditor;
$(function(){
	introeditor=$("#goods_intro").xheditor({skin:'vista',tools:"Cut,Copy,Paste,Pastetext,Separator,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,Separator,Align,List,Outdent,Indent,Separator,Link,Unlink,Img,Table,Separator,Fullscreen,About"});
	$("#goods_intro").val("");
});

function introimage(id,imagepath){
	var is=$("#image_size_id").val();
	if(is==""){
		$("#image_size_id").val(id);
	}else{
		$("#image_size_id").val(is+","+id);
	}
	var imagestr="<li id='imgli'><p class='photo'><img src="+imagepath+" width='100' height='100' /></p><p><a href='javascript:;'  onclick='return addIntroImg(this)' >插入</a><a href='javascript:;' name='"+id+"' onclick='return delIntroImg(this)'>删除</a></p></li>";
	$("#introimage").append(imagestr);

}

function addIntroImg(obj){
    var li=$(obj).parent().parent().children(".photo").children("img").attr("src");
    var str=li.substring(li.indexOf("uploadfiles"));
	introeditor.appendHTML("<img src="+str+"/>");
	return false;
}

function delIntroImg(obj){
	if(!confirm('你真的要删除这张图片吗?')){
       return;
		}
	var path=$(obj).parent().parent().children(".photo").children("img").attr("src");
	var is=$("#image_size_id").val();
	var iid=$(obj).attr('name');
	if(is==""){
		return;
	}
    var param={
          iid:iid,
          path:path
    	  };
    $.post("<?php echo $this->_url('goods/swfdelimage');?>",param,function(data){
        if(data=='1'){
            	var is=$("#image_size_id").val();
          		var myArray=is.split(",");
          		var a;
          		for(i=0;i<myArray.length;i++){
                      if(myArray[i]==iid){
                      	a=i;
                      	break;
                        }
          		}
          		myArray.splice(a,1);
          		var isid=myArray.join(",");
          		$("#image_size_id").val(isid);
          		$(obj).parent().parent().remove();
             }else{
                alert('删除失败');
                 }
        });
}

function AddContentImg(ImgName,classId){
	var obj = document.getElementById("goods_intro").previousSibling.children[0];
	obj.innerHTML = obj.innerHTML + "<br><IMG src='./"+ImgName+"' /><br>";
}


function checkForm() {
	var goods_name = document.getElementsByName("goods_name")[0];
	var goods_price = document.getElementById("goods_price");
	var transport_price = document.getElementById("transport_price");
	var goods_number = document.getElementById("goods_number");

	var num = /^[0-9]+(.[0-9]*)?$/;

	if (document.getElementsByName("cat_id")[0].value==0){
		alert("请选择分类！");
		return false;
	} else if(goods_name.value==''){
		alert("商品名称不能为空！");
		goods_name.focus();
		return false;
	}
	if (goods_price.value !=''){
		if (!goods_price.value.match(num)){
			alert('商品价格格式不正确');
			goods_price.focus();
			return false;
		}
	}
	if(transport_price.value !=''){
		if (!transport_price.value.match(num)){
			alert("运费格式不正确");
			transport_price.focus();
			return false;
		}
	}
	if (goods_number.value !=''){
		if(!goods_number.value.match(num)){
			alert('库存格式不正确');
			goods_number.focus();
			return false;
		}
	}
	return true;
} 
</script>
<style>


textright {
   text-align : right;
}
.index_tab {
    margin-top: 10px;
}

.index_tab ul {
    clear: both;
    margin: 0px;
    padding: 0px;
}
.index_tab ul li {
    float: left;
    margin-right: 3px;
    width: 100px;
    height: 30px;
    position: relative;
    list-style: none outside none;
    text-align: center;
    line-height: 30px;
}

.index_tab ul li a:hover, .index_tab ul li .current {
    background: none repeat scroll 0% 0% rgb(255, 255, 255);
    border-width: 1px 1px 0px;
    border-style: solid solid none;
    border-color: rgb(236, 236, 236) rgb(236, 236, 236) -moz-use-text-color;
    -moz-border-top-colors: none;
    -moz-border-right-colors: none;
    -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-image: none;
}
.index_tab ul li a {
    border-right: 1px solid rgb(236, 236, 236);
    border-width: 0px 1px 1px;
    border-style: none solid solid;
    border-color: -moz-use-text-color rgb(236, 236, 236) rgb(236, 236, 236);
    -moz-border-top-colors: none;
    -moz-border-right-colors: none;
    -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-image: none;
    display: block;
    height: 28px;
    padding-top: 2px;
    font-weight: bold;
    font-size: 14px;
    background: url("../images/memberlist_th_bg.gif") repeat-x scroll center top transparent;
    position: relative;
    bottom: -1px;
}
.main_right table a {
    color: rgb(247, 122, 7);
    text-decoration: underline;
}
.tab_box {
    border: 1px solid rgb(236, 236, 236);
    overflow: hidden;
    padding: 8px 10px;
    width: 690px;
    margin-top: 4px;
    text-align: left;	
}
.main_right table a {
    color: rgb(247, 122, 7);
    text-decoration: underline;
}
.main_right table textarea {
    border: 1px solid rgb(153, 153, 153);
}
.main_right table input[type="text"] {
    border: 1px solid rgb(153, 153, 153);
    padding: 3px 0px 0px 3px;
    width: 150px;
}
.main_right table span {
    color: rgb(255, 102, 0);
    font-weight: bold;
}
.imgPan {
    width: 570px;
    overflow: hidden;
}
.imgPan li {
    float: left;
    text-align: center;
}
.imgPan li .photo {
    width: 100px;
    height: 100px;
    margin-right: 10px;
    border: 1px solid rgb(204, 204, 204);
}
.imgPan li p {
    margin-bottom: 10px;
}
.pagenav .upPage, .pagenav .nextPage {
    width: 52px;
    color: rgb(170, 170, 170);
    text-decoration: none;
}
.pagenav a.num {
    color: rgb(170, 170, 170);
    text-decoration: none;
}

.pagenav .now {
    background-color: rgb(238, 238, 238);
    color: rgb(170, 170, 170);
}
.attr_class {
    background: none repeat scroll 0 0 #FFF2E6;
}
.attr_class div.div {
    border: 2px solid #FFFFFF;
    padding: 3px;
}
.attr_class div span.left {
    display: block;
    float: left;
    margin-left: 10px;
    text-align: right;
    width: 150px;
}
.attr_class div span.right {
    display: block;
    float: left;
    margin-left: 5px;
    text-align: left;
    width: 350px;
}
.attr_class div span.right input {
    margin-left: 5px;
}



</style>  
</head>
<body>
<psp:tags     htmlname='user_topnav1'  iconname='usertopnav1' />
<psp:tags     htmlname='user_topsearch'  iconname='usertopsearch' />

<div class="main">
	<div class="main-left">
    	<div class="title">会员管理中心</div>
        <psp:tags     htmlname='user_menulist'  iconname='usermenulist' />
    </div>
<link href="<?php echo $this->_webroot('/user/css/goodaddoredit.css'); ?>" rel="stylesheet" type="text/css" />   
    <div class="main-right main_right">
	

            <div class="cont">
                <div class="cont_title">店铺商品分类<span class="tr_op"><a href="<?php echo $this->_url('goods/ulist');?>">商品管理</a></span></div>
              
			<form action="<?php echo $this->_url('goods/add');?>" method="post" name="form_goods_add" onsubmit="return checkForm();" enctype="multipart/form-data">
				<table width="100%" style="border:0" cellspacing="0">
					<tr><td class="textright" width="130">商品分类：</td>
						<td>&nbsp;<span id="show_cat_name">未选择分类</span> &nbsp;&nbsp;<a href="javascript:;" onclick="showbgdiv();" style="color:#F1A24C; font-weight:bold;text-decoration:underline;">编辑分类</a>
						<input name="cat_id" value='' type="hidden"></td>
					</tr>
					<tr>
						<td class="textright">商品品牌：</td>
						<td id="brand_box">&nbsp;&nbsp;</td>
					</tr>
					<tr>
						<td class="textright">商品类型：</td>
						<td><input type="radio" name="type_id" value="1" checked />全新 &nbsp;&nbsp;<input type="radio" name="type_id" value="2" />二手 &nbsp;&nbsp;<input type="radio" name="type_id" value="3" />闲置 </span></td>
					</tr>
					<tr id="goods_attr_tr">
						<td class="textright">商品属性：</td>
						<td class="attr_class" id="attr_content"></td>
					</tr>
					<tr>
						<td class="textright">商品名称：</td>
						<td><input type="text" name="goods_name" value="<?php echo  $goods_info['goods_name'];?>" style="width:395px;" maxlength="200" /> <span class="red">*</span></td>
					</tr>
					 <tr><td class="textright">店铺商品分类：</td>
						<td><select name="ucat_id" id="ucat_id">
							<option value="0">
								选择分类
							</option>
							<?php echo  $html_shop_category;?>
						</select>
			         	  <span class="red">*</span> <span id="ucate_add"><a href="javascript:;" onclick="showinput();">添加自定义分类</a></span>
			         	  <span id="ucate_span" style="display:none;"><input type="text" value="" style="width:115px;" id="ucat_input" /><input type="button" value="增加" onclick="addnewucat();" /></span>
		         	  </td>
					</tr>
					<tr><td class="textright">商品参考价格：</td>
						<td><input type="text" id="goods_refer_price" name="goods_refer_price" value="<?php echo  $goods_info['goods_refer_price'];?>" style="width:80px;text-align:right;" maxlength="8" /> 元 (该价格用来做为参考价格) </td>
					</tr>					
					
					<tr><td class="textright">商品价格：</td>
						<td><input type="text" id="goods_price" name="goods_price" value="<?php echo  $goods_info['goods_price'];?>" style="width:80px;text-align:right;" maxlength="8" /> 元 (商品价格等于0时即为面议) </td>
					</tr>

<input type="hidden" value="0"  name="is_transport_template" />
<input type="hidden" name="transport_price" id="transport_price" value="0"  />					
<!--					
					<tr>
						<td class="textright">运费方式：</td>
						<td class="">
							<input type="radio" value="1" id="is_transport_template" onclick="chostransporttype(1)"  name="is_transport_template" /> 选择运费模板&nbsp;&nbsp;
							<input type="radio"  onclick="chostransporttype(0)" value="0" name="is_transport_template" />运费
						</td>
					</tr>

					<tr id="transport1" style="display:none;">
						<td class="textright">
							邮费模板费用：
						</td>
						<td>
						<?php if(is_array($transport_template_list)){?>
							<?php foreach($transport_template_list as $value){?>
							    <?php $value = $value['goodstransport']; ?>
								<input type="radio" name="transport_template_id"   value="<?php echo $value['id'];?>"  /><?php echo $value['transport_name'];?>&nbsp;<a href="<?php echo $this->_url('transport/tedit');?>?id=<?php echo $value['id'];?>" target="_blank">修改运费模板</a><br />
							<?php }?>
						<?php }?>
						
						<a href="<?php echo $this->_url('transport/index');?>" target="_blank">新增运费模板</a>
						</td>
					</tr>

					<tr  id="transport2" style="display:none;">
						<td class="textright">运费费用：</td>
						<td><input type="text" name="transport_price" id="transport_price" value="<?php echo   $goods_info['transport_price'];?>" style="width:80px; text-align:right;" maxlength="8" /> 元</td>
					</tr>
-->
					<tr><td class="textright"><span id="picspan">商品图片</span></td>
						<td><input type="file" name="attach[]" id="" value="" onchange="showimg(this)" />
						<!-- <input type="button" value="使用已上传图片" onclick="get_img_list('img_select1','1','img_list1',this)"> <span class="red">*</span> --><br />
						图片应小于1M，jpg、png或gif格式。建议为300</>x300像素
						<!-- <div id="img_select1" style="width:600px;  display:none;">
	                    	<span id="img_list1">

	                    	</span>
						</div> -->
						</td></tr>
					<tr><td valign="top" class="textright">商品介绍：</td>
						<td style=" line-height:18px">
			                  <div class="index_tab">
			                	<ul>
			                      <li><a id="style1" style="font-size:12px;color:#333;font-weight:normal; text-decoration:none" class="current" href="javascript:;" onclick="change_style('style1')">商品介绍</a></li>
			                      <li><a id="style2" style="font-size:12px;color:#333;font-weight:normal;text-decoration:none" href="javascript:;" onclick="change_style('style2');get_img_list('img_select3','2','img_list3',this)">使用已上传图片</a></li>
			                    </ul>
			                  </div>
			                  <div id="display_order" class="tab_box">
								<textarea name="goods_intro" id="goods_intro" cols="95" rows="15"><?php echo  $goods_info['goods_intro'];?></textarea>
								<div class="clear"></div>
								<div><span>最近上传的五张图片</span></div>
								<div id="img_select2" style="width:600px;">
			                    	<div id="img_list2" class="imgPan">
										<ul id="introimage" class="clearfix">
										<?php foreach($result['result'] as $v){?>
										<li>
											<p class="photo"><img src="<?php echo  $v['img_url'] ;?>" width="100" height="100" onerror="this.src='skin/default/images/nopic.gif'"/></p>
											<p><a href='javascript:;'  onclick='return addIntroImg(this)' >插入</a><a href='javascript:;' name='<?php echo $v["id"];?>' onclick='return delIntroImg(this)'>删除</a></p>
										</li>
										<?php }?>
										</ul>
			                    	</div>
								</div>
						<div id="fsUploadProgress">
						</div>
						<div id="divStatus"></div>
						<div>
							<span id="spanButtonPlaceHolder"></span>
							<input id="btnCancel" type="button" value="取消" onclick="swfu.cancelQueue();" disabled="disabled" style="display:none" />
							<input type="hidden" id="image_size_id" name="image_size_id" value="<?php echo  $imagelistid ;?>"/>
						</div>
						<span >按ctrl键选择多个文件</span>
							  </div>
			                  <div id="display_favorite" class="tab_box" style="display:none;">
								<div id="img_select3" style="width:600px;">
			                    	<div id="img_list3" class="imgPan">
										<ul id="introimage1" class="clearfix">
										<?php foreach($result['result'] as $v){?>
										<li>
											<p class="photo"><img src="<?php echo  $v['img_url'] ;?>" width="100" height="100" onerror="this.src='skin/default/images/nopic.gif'"/></p>
											<p><a href='javascript:;'  onclick='return addIntroImg(this)' >插入</a><a href='javascript:;' name='<?php echo $v["id"];?>' onclick='return delIntroImg(this)'>删除</a></p>
										</li>
										<?php }?>
										</ul>
			                    	</div>
								</div>
			                  </div>
							
<!--						<textarea name="goods_intro" id="goods_intro" cols="65" rows="15"><?php echo  $goods_info['goods_intro'];?></textarea>-->
					</td></tr>
					<tr><td class="textright">批发说明：</td><td>
					<textarea name="goods_wholesale" cols="45" rows="3"><?php echo  $goods_info['goods_wholesale'];?></textarea>
					</td></tr>
					<tr><td class="textright">所属供应商：</td><td>
							<select name="supplier_id">
								<option value='0'>请选择...</option>
								<?php foreach($supplierlist as $v) { ?>
								<option value='<?php echo $v['supplier']['sup_user_id'];?>' <?php if($v['supplier']['sup_user_id']==$goods_info['supplier_user_id']){?> selected<?php }?> ><?php echo $v['supplier']['sup_name'];?></option>
								<?php } ?>							
							</select>	
					</td></tr>						
					<tr><td class="textright">库存量：</td>
						<td><input type="text" name="goods_number" id="goods_number" value="<?php echo  $goods_info['goods_number'];?>" style="width:80px; text-align:right;" maxlength="5" /> 件</td></tr>
					<tr><td class="textright">关键字：</td>
						<td><input type="text" name="keyword" value="<?php echo  $goods_info['keyword'];?>" style="width:250px;" maxlength="200" />  多个关键字，请以空格或逗号进行分割</td></tr>
					<tr><td class="textright">上架：</td>
						<td><input type="checkbox" name="is_on_sale" value="1" <?php if($goods_info['is_on_sale']){ echo "checked";?><?php }?> />
							打勾表示允许查看，否则不允许查看。</td></tr>
					<tr><td class="textright">加入推荐：</td><td>
						<input type="checkbox" name="is_best" value="1" <?php if($goods_info['is_best']){ echo "checked";}?> />
						精品&nbsp;
						<input type="checkbox" name="is_promote" value="1" <?php if($goods_info['is_promote']){ echo "checked";;}?> />
						特价&nbsp;
						<input type="checkbox" name="is_new" value="1" <?php if($goods_info['is_new']){ echo "checked";}?> />
						新品&nbsp;
						<input type="checkbox" name="is_hot" value="1" <?php if($goods_info['is_hot']){ echo "checked";}?> />
						热销&nbsp;<br/>
						您最多可以设置5精品，5特价，5新品，5热销，过多设置无效
					</td></tr>
					<tr><td colspan="2" class="center" style="text-align:center"><input class="submit" type="submit" name="submit" value="添加商品" /></td></tr>
				</table>
			</form> 
			  
			  
			  
			  
            </div>
	
	

        

    </div>
    <div class="clear"></div>
</div>

<div class="footer">
    <psp:tags     htmlname='user_footer_helper'  iconname='userfooterhelper' />

</div>

    <div id="bgdiv" style="display:none;"></div>
	<div id="category_select" style="display:none;">
		<div class="category_title_1">
		
		<?php if($isset_payment){?>
		请选择分类</div>
		<ul id="select_first" class="ulselect">
			<?php foreach($category_info as $k=>$v){?>
				<?php if($v['goodscategories']['parent_id']==0){?>
				<li title="<?php echo  $v['goodscategories']['id'];?>"><?php echo  $v['goodscategories']['cat_name'];?></li>
				<?php }?>
			<?php }?>
		</ul>
		<ul id="select_second" class="ulselect"></ul>
		<ul id="select_third" class="ulselect"></ul>
		<ul id="select_fourth" class="ulselect"></ul>

		<div class="category_com"><input class="submit" type="button" value="提 交" onclick="postcatid();" /></div>
		<?php  } else {?>
		<span onclick="hidebgdiv();">关闭</span>
		请选择分类</div>
		<div align="center" style="margin-top:60px;font-weight:bolder;font-size:14px;color:#333">您还没有设置支付方式!</div>
		<br />
		<br />
		<br />
		<br />
		<div class="category_com"><input class="submit" type="button" value="提 交" onclick="postcatid1();" /></div>
		<?php }?>
	</div>
<script language="JavaScript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js');?>"></script>
<script language="JavaScript">
<!--
var select_value = {'first':'','second':'','third':'','fourth':'','value':'0'};

function showbgdiv() {
	var bgdiv = document.getElementById("bgdiv");
	var goods_attr_tr = document.getElementById("goods_attr_tr");
	var category_select = document.getElementById("category_select");
	var ucat_id = document.getElementsByName("ucat_id")[0];
	var brand_box = document.getElementById("brand_box");
	ucat_id.style.display = "none";
	goods_attr_tr.style.display = "none";
	bgdiv.style.display = '';
	category_select.style.display = '';
	brand_box.style.display = 'none';
	var width = document.body.clientWidth;
	var left = "100";
	if(width) {
		left = (width-800)/2;
	}
	//category_select.style.left = left+"px";
	//bgdiv.style.left = (width-960)/2+"px";
}

function hidebgdiv() {
	var bgdiv = document.getElementById("bgdiv");
	var category_select = document.getElementById("category_select");
	var goods_attr_tr = document.getElementById("goods_attr_tr");
	var ucat_id = document.getElementsByName("ucat_id")[0];
	var brand_box = document.getElementById("brand_box");
	ucat_id.style.display = "";
	bgdiv.style.display = 'none';
	category_select.style.display = 'none';
	brand_box.style.display = 'none';
	goods_attr_tr.style.display = "";
}

function bodyonload() {

	var cat_id = document.getElementsByName("cat_id")[0];
	if(cat_id.value>0) {

	} else {
		showbgdiv();
	}

	var lis = document.getElementsByTagName("li");
	for(var i=0; i<lis.length; i++) {
		lis[i].onclick = selectli;
	}
}
var aaa=document.getElementById("select_first");
function selectli() {
	var tlis = this.parentNode.childNodes;
	for(var j=0; j<tlis.length; j++) {
		tlis[j].className = '';
	}
	this.className = "select";

	var nextul = null;
	if(this.parentNode.id=='select_first') {
		nextul = document.getElementById("select_second");
		select_value.first = this.innerHTML;
		select_value.second = '';
		select_value.third = '';
		select_value.fourth = '';
		nextul.innerHTML = '';
		document.getElementById("select_third").innerHTML = '';
		document.getElementById("select_fourth").innerHTML = '';
	} else if(this.parentNode.id=='select_second') {
		nextul = document.getElementById("select_third");
		select_value.second = ' > '+this.innerHTML;
		select_value.third = '';
		select_value.fourth = '';
		nextul.innerHTML = '';
		document.getElementById("select_fourth").innerHTML = '';
	} else if(this.parentNode.id=='select_third') {
		nextul = document.getElementById("select_fourth");
		select_value.third = ' > '+this.innerHTML;
		select_value.fourth = '';
		nextul.innerHTML = '';
	} else if(this.parentNode.id=='select_fourth'){
		select_value.fourth = ' > '+this.innerHTML;
	}
	select_value.value = this.title;
	if(nextul) {
		var cat_id = this.title;
		var name = this.parentNode.id;
		ajax("<?php echo $this->_url('goods/getcatlist');?>","POST","cat_id="+cat_id,function(data){
		    
			if(data!='-1') {
				var newli;
				for(var i=0; i<data.length; i++) {
					aaa=nextul;
					newli = document.createElement("li");
					newli.onclick = selectli;
					newli.title = data[i].cat_id;
					newli.innerHTML = data[i].cat_name;
					nextul.appendChild(newli);
				}
			}
		},'JSON');
	}
}

function postcatid() {
	var tlis = aaa.childNodes;
	var flag=false;
	for(var j=0; j<tlis.length; j++) {
		if(tlis[j].className == 'select'){
			flag=true;
			var cat_id = document.getElementsByName("cat_id")[0];
			var show_cat_name = document.getElementById("show_cat_name");
			show_cat_name.innerHTML = select_value.first + select_value.second + select_value.third + select_value.fourth;
			cat_id.value = select_value.value;
			changeAttr(select_value.value);
			get_brand_list(cat_id.value);
			hidebgdiv();
			}
	}
}
function postcatid1(){
	location.href="modules.php?app=shop_payment";
}
function changeAttr(value) {
	ajax("<?php echo $this->_url('goods/getattributelist');?>","POST","v="+value,function(data){
		changeAttrTr(data);
	},'JSON');
}

function changeAttrTr(objvalue) {
	var attr_content = document.getElementById("attr_content");
	attr_content.innerHTML = '';
	var html = '';
	var temp = '';
	for(var i=0; i<objvalue.length; i++) {
		temp = formatFormElement(objvalue[i].attr_id,objvalue[i].input_type,objvalue[i].attr_name,objvalue[i].attr_values);
		html += '<div class="div"><span class="left">'+objvalue[i].attr_name+'：</span><span class="right">'+temp+'</span><div class="clear"></div></div>';
	}
	attr_content.innerHTML = html;
}
//属性input类型 0:TEXT,1:SELECT,2:radio,3:checkbox
function formatFormElement(id,type,name,value) {
	var optionValue;
	var cValue = str = '';
	//if(goodsAttr[id]) {
	//cValue = goodsAttr[id];
	//}
	if(type==0) {
		str = '<input type="text" name="attr[' + id + ']" value="'+cValue+'" maxlength="200" />';
	} else if (type==1 && value!='') {
		optionValue = value.split("\n");
		str = '<select name="attr[' + id + ']">';
		str += '<option value="0">请选择' + name + '</option>';
		for(var i=0; i<optionValue.length; i++) {
			if(optionValue[i] == cValue) {
				str += '<option value="'+optionValue[i]+'" selected>' + optionValue[i] + '</option>';
			} else {
				str += '<option value="'+optionValue[i]+'">' + optionValue[i] + '</option>';
			}
		}
		str += '</select>';
	} else if (type==2 && value!='') {
		optionValue = value.split("\n");
		for(var i=0; i<optionValue.length; i++) {
			if(optionValue[i] == cValue) {
				str += '<input type="radio" name="attr[' + id + ']" value="'+optionValue[i]+'" checked />' + optionValue[i] + ' ';
			} else {
				str += '<input type="radio" name="attr[' + id + ']" value="'+optionValue[i]+'" />' + optionValue[i] + ' ';
			}
		}
	} else if (type==3 && value!='') {
		var regv = cValue.replace(/[\r\n]/g,"|");
		if(regv) {
			var re = new RegExp("(("+regv+")|([^\r\n]+))[\r\n]*","g");
		} else {
			var re = new RegExp("((iwebshop)|([^\r\n]+))[\r\n]*","g");
		}
		var str = value.replace(re,"<input type='checkbox' name='attr[" + id + "][]' value='$1' checked$3 />$1");
	}
	return str;
}

function showimg(obj) {
	var picspan = document.getElementById("picspan");
	picspan.innerHTML = '';
	var Img = new Image();
	Img.id = "goods_pic";

		if(navigator.userAgent.indexOf("MSIE")>0) {
			Img.src = obj.value;
		} else {
			Img.src = obj['files'][0].getAsDataURL();
		}

	picspan.appendChild(Img);
	//imgwh();
	setTimeout("imgwh()",100);
}

function imgwh() {
	var Img = document.getElementById("goods_pic");
	var w = Img.width;
	var h = Img.height
	if(w>h) {
		Img.height = h*80/w;
		Img.width = '80';
		Img.style.marginTop = (80-Img.height)/2+'px';
	} else {
		Img.width = w*80/h;
		Img.height = '80';
	}
}

function showinput() {
	var ucate_add = document.getElementById("ucate_add");
	var ucate_span = document.getElementById("ucate_span");
	ucate_add.style.display = 'none';
	ucate_span.style.display = '';
}
function hideinput() {
	var ucate_add = document.getElementById("ucate_add");
	var ucate_span = document.getElementById("ucate_span");
	ucate_add.style.display = '';
	ucate_span.style.display = 'none';
}

function addnewucat() {
	var ucat_input = document.getElementById("ucat_input");
	var ucat_id = document.getElementsByName("ucat_id")[0];
	v = ucat_input.value;
	if(v=='') {
		alert("分类名称不能为空！");
		return false;
	} else {
		ajax("<?php echo $this->_url('goods/getucategoryadd/');?>","POST","name="+v,function(data){
			if(data!='-1') {
				var newoption = document.createElement("option");
				newoption.value = data;
				newoption.selected = 'selectes';
				newoption.innerHTML = v;
				ucat_id.appendChild(newoption);
				alert("添加成功");
			} else {
				alert("添加失败");
			}
		},'JSON');
		hideinput();
	}
}

function get_brand_list(cat_id_value){
	ajax("<?php echo $this->_url('goods/getcatbrandlist/');?>","POST","cat_id="+cat_id_value,function(data){
		var str="<select name='brand_id'>";
		for(i=0;i<data.length;i++){
			str+="<option value='"+data[i].id+"'>"+data[i].brand_name+"</option>";
		}
		str+="<option value='0'>其它品牌</option>";
		str+="</select>";
		document.getElementById("brand_box").innerHTML=str;
		document.getElementById("brand_box").style.display='';
	},'JSON');
}

function chostransporttype(m){
	var obj=document.form_goods_add;
	var radioobj=document.getElementsByName("transport_template_id");
	if(m==1){
		obj.transport_price.value=0.00;
		document.getElementById("is_transport_template").checked=true;
		document.getElementById("transport1").style.display='';
		document.getElementById("transport2").style.display='none';
		var b=0;
		for(i=0;i<radioobj.length;i++){
			if(radioobj[i].checked){
				b++;
			}
		}
		if(b!=0){
			radioobj[0].checked=true;
		}
	}else{
		document.getElementById("transport2").style.display='';
		document.getElementById("transport1").style.display='none';
		for(i=0;i<radioobj.length;i++){
			radioobj[i].checked=false;
		}
	}
}

function change_style(flag) {
	if (flag =='style1'){
		document.getElementById('style1').className="current";
		document.getElementById('style2').className="";
		document.getElementById('display_order').style.display="block";
		document.getElementById('display_favorite').style.display="none";
	}
	if (flag =='style2'){
		document.getElementById('style1').className="";
		document.getElementById('style2').className="current";
		document.getElementById('display_order').style.display="none";
		document.getElementById('display_favorite').style.display="block";
	}
}
function get_img_list(itemid,i,imgid,page){
		ajax("<?php echo $this->_url('goods/getshopimgselect/');?>","POST","page="+page,function(data){
			document.getElementById(imgid).innerHTML = data;
			var a=data.substring(0,data.indexOf("</span>"));
			var b=a.substring(a.indexOf(">")+1);
			document.getElementById("image_size_id").value=b;
		});
}

//-->
</script>

</body>
</html>